<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\grid\GridView;
use yii\widgets\Pjax;

$cssString = '
.table-striped > tbody > tr:nth-of-type(odd) {background-color: #f5f5f5;}
.table-striped > tbody > tr > th {width:20%}
';
$this->registerCss($cssString);

/* @var $this yii\web\View */
/* @var $model ua_backend\models\User */

$this->title = Yii::t('app', 'Administrator Detail');
$this->params['breadcrumbs'][] = ['label' => Yii::t('menu', 'Administrator'), 'url' => ['/admin/list']];
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="row">
    <div class="col-xs-12 text-gray2 fs-12" style="height: 45px">
        <div class="flex flex-between">
            <?php
            $url = Yii::$app->user->getReturnUrl();
            echo Html::a('<i class="fa fa-angle-left"> </i> '.Yii::t('app','Back'),
                $url, ['class' =>  'btn btn-primary']);
            ?>

            <div class="flex flex-end">
                <?php
                if(Yii::$app->user->id != $model->id){
                    if($model->status === 1){
                        $html = '<div class="modal-confirm pd-lr-15"><h2>'.Yii::t('app','Are you sure?').'</h2>'.
                            '<p>'.Yii::t('app', 'Are you sure you want to disabled this account?').'</p></div>';

                        echo Html::a('<i class="fa fa-user"> </i> '.Yii::t('app', 'Disabled Account'), ['toggle-status','id'=>$model->id], [
                            'class' => 'btn btn-danger',
                            'data'=>[
                                'confirm' => $html,
                                'method' => 'post'
                            ]
                        ]);
                    }else{
                        echo Html::a('<i class="fa fa-user"> </i> '.Yii::t('app', 'Active Account'), ['toggle-status','id'=>$model->id], [
                            'class' => 'btn btn-success',
                        ]);
                    }
                }


                echo '<div class="wspace10"></div>';

                echo Html::a('<i class="fa fs-12 fa-key"> </i> '.Yii::t('app', 'Change Password'), ['change-pwd','id'=>$model->id], [
                    'class' => 'btn btn-primary',
                ]);
                ?>
            </div>
        </div>
    </div>
</div>

<div class="box box-primary">
    <div class="box-header">
        <h3><?=Yii::t('app','Basic Information')?></h3>
        <hr>
    </div>
    <div class=" box-body">
        <?= DetailView::widget([
            'model' => $model,

            'attributes' => [
                [
                    'attribute' => 'id',
                ],

                'username' => [
                    'attribute' => 'username',
                    'label' => Yii::t('app', 'Username'),
                    //'enableSorting' => false,
                ],

                'realname' => [
                    'attribute' => 'realname',
                    'label' => Yii::t('app','Realname'),
                    //'enableSorting' => false,
                ],

                'email' => [
                    'attribute' => 'email',
                    'label' => Yii::t('app','Email'),
                ],

                'mobile' => [
                    'attribute' => 'mobile',
                    'label' => Yii::t('app','Mobile'),
                ],

                [
                    'attribute' => 'created_at',
                    'label' => Yii::t('app', 'Created at'),
                    'format' => ['date', 'php:Y-m-d h:i:s']
                ],

                'status' => [
                    'attribute' => 'status',
                    'label' => Yii::t('app','Status'),
                    'format'=> 'raw',
                    'value' => function($model){
                        return Yii::$app->params['Status'][$model->status];
                    }
                ],
            ],
        ]) ?>
    </div>
</div>


<div class="clearfix"></div>
<div class="space50"></div>
